from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings.base')

app = Celery('myproject')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

app.conf.beat_schedule = {
    'calculate-stock-indicators': {
        'task': 'myapp.tasks.calculate_stock_indicators',
        'schedule': crontab(hour='11,15', minute='0', day_of_week='1-5'),
    },
    'send-daily-trading-suggestions': {
        'task': 'myapp.tasks.send_daily_trading_suggestions',
        'schedule': crontab(hour='9', minute='30', day_of_week='1-5'),  # 每个交易日早上9:30发送
    },
} 